package cn.edu.ncu.housinghub.dto.response.user;

import cn.edu.ncu.housinghub.entity.user.IdentityInfo;
import cn.edu.ncu.housinghub.entity.user.User;

/**
 * 用户个人资料响应DTO
 */
public class UserProfileResponse {
    
    private Long id;
    private String username;
    private String email;
    private String phone;
    private String gender;
    private String birthday;
    private String city;
    private String bio;
    private String avatar;
    private Integer role;
    private String roleName;
    private Boolean isIdentityVerified;
    private String realName;
    private String identityCard;
    private String createTime;
    
    // 构造函数
    public UserProfileResponse() {}
    
    public UserProfileResponse(User user) {
        this.id = user.getId();
        this.username = user.getUsername();
        this.email = user.getEmail();
        this.phone = user.getPhone();
        this.gender = user.getGender();
        this.birthday = user.getBirthday();
        this.city = user.getCity();
        this.bio = user.getBio();
        this.avatar = user.getAvatar();
        this.role = user.getRole();
        this.roleName = getRoleNameByCode(user.getRole());
        this.isIdentityVerified = user.getIsIdentityVerified();
        this.createTime = user.getCreateTime() != null ? user.getCreateTime().toString() : null;
        // 实名认证信息需要单独查询
        this.realName = null;
        this.identityCard = null;
    }

    public UserProfileResponse(User user, IdentityInfo identityInfo) {
        this(user); // 调用上面的构造函数
        if (identityInfo != null) {
            this.realName = identityInfo.getRealName();
            this.identityCard = identityInfo.getIdCard();
        }
    }
    
    /**
     * 根据角色代码获取角色名称
     */
    private String getRoleNameByCode(Integer roleCode) {
        if (roleCode == null) return "未知";
        switch (roleCode) {
            case 1: return "租客";
            case 2: return "房东";
            case 3: return "中介";
            default: return "未知";
        }
    }
    
    // Getter和Setter方法
    public Long getId() {
        return id;
    }
    
    public void setId(Long id) {
        this.id = id;
    }
    
    public String getUsername() {
        return username;
    }
    
    public void setUsername(String username) {
        this.username = username;
    }
    
    public String getEmail() {
        return email;
    }
    
    public void setEmail(String email) {
        this.email = email;
    }
    
    public String getPhone() {
        return phone;
    }
    
    public void setPhone(String phone) {
        this.phone = phone;
    }
    
    public String getGender() {
        return gender;
    }
    
    public void setGender(String gender) {
        this.gender = gender;
    }
    
    public String getBirthday() {
        return birthday;
    }
    
    public void setBirthday(String birthday) {
        this.birthday = birthday;
    }
    
    public String getCity() {
        return city;
    }
    
    public void setCity(String city) {
        this.city = city;
    }
    
    public String getBio() {
        return bio;
    }
    
    public void setBio(String bio) {
        this.bio = bio;
    }
    
    public String getAvatar() {
        return avatar;
    }
    
    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }
    
    public Integer getRole() {
        return role;
    }
    
    public void setRole(Integer role) {
        this.role = role;
    }
    
    public String getRoleName() {
        return roleName;
    }
    
    public void setRoleName(String roleName) {
        this.roleName = roleName;
    }
    
    public Boolean getIsIdentityVerified() {
        return isIdentityVerified;
    }
    
    public void setIsIdentityVerified(Boolean isIdentityVerified) {
        this.isIdentityVerified = isIdentityVerified;
    }
    
    public String getRealName() {
        return realName;
    }
    
    public void setRealName(String realName) {
        this.realName = realName;
    }
    
    public String getIdentityCard() {
        return identityCard;
    }
    
    public void setIdentityCard(String identityCard) {
        this.identityCard = identityCard;
    }
    
    public String getCreateTime() {
        return createTime;
    }
    
    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }
}
